<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="js/jquery-3.6.0.min.js"></script>
    <script>
        $(function () {
            $("#upload_image").click(function () {
                var file = document.getElementById("file").files[0];
                console.log(file)
                var data = new FormData();
                data.append("imageFile", file);
                $.ajax({
                    type: "post",
                    url: "http://localhost:8081/upload3",
                    contentType: "multipart/form-data",
                    data: data,
                    type: 'POST',
                    cache : false,
                    processData : false,
                    contentType : false,
                    timeout: 3000,
                    success: function (result) {
                        alert("添加成功");
                    },
                    error: function (result) {
                        alert("添加失败!");
                    }
                });
            });
        })
    </script>

</head>
<body>
<form>
    <input type="file" name="headerImg" id="file"/>
    <input type="button" id="upload_image" value="开始上传"/>
</form>
</body>
</html>

